package com.example.exam.controller;

import com.example.exam.service.CorrectExamPaperService;
import com.example.exam.util.ResultVOUtil;
import com.example.exam.vo.ResultVO;
import com.example.exam.vo.TeacherCorrectVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author shishuqian
 * date 2021/5/11
 * time 16:07
 **/
@RestController
@RequestMapping("/teacherCorrect")
@Api(value = "老师批改controller",tags = {"教师批改接口"})
public class TeacherCorrectController {

    @Autowired
    private CorrectExamPaperService correctExamPaperService;

    @ApiOperation(value = "根据id获取要批改的试卷")
    @ApiResponses({@ApiResponse(code = 200,message = "OK",response = TeacherCorrectVO.class)})
    @GetMapping("/getQuestion/{examPaperAnswer_id}")
    public ResultVO teacherGetQuestion(@PathVariable("examPaperAnswer_id") Integer examPaperAnswer_id){
        TeacherCorrectVO teacherCorrectVO = correctExamPaperService.teacherGetQuestion(examPaperAnswer_id);
        if (teacherCorrectVO != null){
            return ResultVOUtil.success(teacherCorrectVO);
        }else {
            return ResultVOUtil.error("此答题卷已批改完毕");
        }

    }

    @ApiOperation(value = "传回老师批改信息")
    @PostMapping("/save")
    public void teacherCorrect(@RequestBody TeacherCorrectVO correctVO){
        correctExamPaperService.teacherCorrect(correctVO);
    }


}
